
import time


def get_logger(log_dir='C:\zxc\data\shwj'):
    try:
        from loguru import logger
    except Exception as e:
        import pip
        pip.main(["install", "--user", "loguru"])
        from loguru import logger
        print(f'pip install loguru')

    t = str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()))
    logFile="%s/run_%s_%s.log" % (log_dir, 'progname', t)
    #logger.add(logFile, rotation='200KB', compression='zip', retention="72h")
    logger.add(logFile, rotation='200KB')

    return logger


# print = logger.info

if __name__ =='__main__':
    # test_HuoniMessClient()
    log_dir = r'D:\data\save\fuba_tianxian'  # 日志目录
    logger = get_logger(log_dir)
    logger.info('test log info')